package com.br.fmn.clubedoimovel.negocio.map;

import com.br.fmn.clubedoimovel.R;
import com.br.fmn.clubedoimovel.negocio.model.ApplicationMapModel;
import com.google.android.maps.MapView;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

public class MyLocation implements LocationListener {

	private MapView mapView;
	private Context context;
	private LocationManager locationManager;
	private ApplicationMapModel appMapModel;

	public MyLocation(MapView mapView, Context context,
			ApplicationMapModel appMapModel) {

		this.mapView = mapView;
		this.context = context;
		this.locationManager = (LocationManager) context
				.getSystemService(context.LOCATION_SERVICE);
		this.appMapModel = appMapModel;
	}

	public void onLocationChanged(Location location) {

		if (location != null) {

			appMapModel.setPinMap(location.getLatitude(),
					location.getLongitude(), R.drawable.pin_myposition);
			locationManager.removeUpdates(this);
		}

	}

	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub

	}

	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub

	}

	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub

	}

}
